#pragma once

#include <string>
#include <unordered_map>
#include "MapFunc.h"
#include "IdManager.h"
#include "Param.h"

using namespace std;

class Component {
    friend class TemplateCenter;
    protected:
        // 组件名称
        string name;
        // 参数表
        unordered_map<string,Param*> paramMap;
        // 组件表
        unordered_map<string,Component*> subComponentMap;
        Component(const string &_name);
        Component(const string &_name,Component* const component);
        
    public:
        ~Component();
        string getName();
        Param* addParam(string name);
        Param* addParam(Param* param);
        Param* copyParam(Param* param);
        bool deleteParam(string name);
        int getParamCount();
        void listAllParam(Param* (&paramList)[]);
        Component* addSubComponent(const string name);
        Component* addSubComponent(Component* component,const string name);
        bool deleteSubComponent(string name);
        int getSubComponentCount();
        void listAllSubComponent(Component* (&subComponentList)[]);
        string toString();
        static Component* strToComponent(istringstream &iss);
        // 抽象方法 获取组件消息
        virtual string getInfo();
        // 抽象方法 执行指令
        virtual void doAsCommend(string cmd);
};